"use strict";
const e = require("../../common/vendor.js"),
  a = require("../../api/request.js"),
  i = require("../../common/assets.js"),
  l = {
    __name: "concern",
    setup(l) {
      const t = e.ref([]),
        n = e.ref(!1),
        o = e.ref(!1),
        u = e.ref(!1);
      async function c() {
        try {
          const e = await a.requestApi("/user_following_author", {
            page: 1
          });
          console.log(e), t.value = e.data, n.value = !(e.data.length > 0), o.value = !(e.data.length > 0), u.value = !1
        } catch (e) {
          "401" == e && (n.value = !0, o.value = !1, u.value = !0)
        }
      }

      function s(a, i) {
        "image" == i ? e.wx$1.navigateTo({
          url: "/pages/details-page/details?_id=" + a
        }) : e.wx$1.navigateTo({
          url: "/pages/details-page/video?_id=" + a
        })
      }
      e.onLoad((() => {
        e.index.$on("loginSuccess", (async e => {
          c()
        })), c()
      }));
      const r = e.ref(1);

      function g() {
        e.wx$1.navigateTo({
          url: "/pages/Login-pop-up/login"
        })
      }
      return e.onReachBottom((async () => {
        r.value++;
        const e = await a.requestApi("/user_following_author", {
          page: r.value
        });
        t.value = [...t.value, ...e.data]
      })), (l, c) => e.e({
        a: t.value.length > 0
      }, t.value.length > 0 ? {
        b: e.f(t.value, ((l, n, o) => e.e({
          a: l.author_data[0].avatarUrl,
          b: e.t(l.author_data[0].nickname),
          c: e.t(l.time_stamp),
          d: "image" == l.fileType
        }, "image" == l.fileType ? {
          e: e.f(l.image.slice(0, 5), ((a, i, t) => e.e({
            a: a
          }, l.image.length > 5 ? {
            b: e.t(l.image.length - 5)
          } : {}, {
            c: i,
            d: e.o((i => function (a, i) {
              e.wx$1.previewImage({
                current: i,
                urls: a
              })
            }(l.image, a)), i)
          }))),
          f: l.image.length > 5
        } : {
          g: l.cover_image.url,
          h: e.o((e => s(l._id, l.fileType)), n)
        }, {
          i: e.t(l.address),
          j: e.t(l.title),
          k: e.t(l.content),
          l: e.o((e => s(l._id, l.fileType)), n),
          m: e.t(l.comments),
          n: e.o((e => s(l._id, l.fileType)), n),
          o: l.isLiked ? e.unref(i.Yidianzan) : e.unref(i.Dianzan),
          p: e.t(l.likes),
          q: e.o((e => async function (e, i, l) {
            i ? (await a.requestApi("/cancel_like", {
              article_id: l
            }), t.value[e].isLiked = !1, t.value[e].likes--) : (await a.requestApi("/user_like", {
              article_id: l
            }), t.value[e].isLiked = !0, t.value[e].likes++)
          }(n, l.isLiked, l._id)), n),
          r: l.isCollect ? e.unref(i.Yishowcang) : e.unref(i.Showcang),
          s: e.t(l.collections),
          t: e.o((e => async function (e, i, l) {
            i ? (await a.requestApi("/cancel_collection", {
              article_id: l
            }), t.value[e].isCollect = !1, t.value[e].collections--) : (await a.requestApi("/collect_travel", {
              article_id: l
            }), t.value[e].isCollect = !0, t.value[e].collections++)
          }(n, l.isCollect, l._id)), n),
          v: n
        }))),
        c: e.unref(i.Pinglun)
      } : {}, {
        d: n.value
      }, n.value ? e.e({
        e: o.value
      }, (o.value, {}), {
        f: u.value
      }, u.value ? {
        g: e.o(g)
      } : {}) : {})
    }
  };
wx.createPage(l);